﻿
using CSharpLibs.Annotations;

#pragma warning disable 0649

namespace System.IO
{
	[Builtin]
	public abstract class FileSystemInfo : Object
	{
		protected string FullPath;

		protected FileSystemInfo(string fsn)
		{ this.FullPath = Path.NormalizePath(fsn, true); }

		public abstract void Delete();

		public DateTime CreationTime
		{
			get 
			{ 
				return FSAccessInfo.GetAccessInfo(this.FullPath).Creation; 
			}

			set
			{
				FSAccessInfo fsi = FSAccessInfo.GetAccessInfo(this.FullPath);
				fsi.Creation = value;
				FSAccessInfo.SetAccessInfo(this.FullPath, fsi);
			}
		}

		public abstract bool Exists { get; }

		public abstract string FullName { get; }

		public abstract string Name { get; }

		public DateTime LastAccessTime
		{
			get
			{
				return FSAccessInfo.GetAccessInfo(this.FullPath).LastAccess;
			}

			set
			{
				FSAccessInfo fsi = FSAccessInfo.GetAccessInfo(this.FullPath);
				fsi.LastAccess = value;
				FSAccessInfo.SetAccessInfo(this.FullPath, fsi);
			}
		}

		public DateTime LastWriteTime
		{
			get
			{
				return FSAccessInfo.GetAccessInfo(this.FullPath).LastWrite;
			}

			set
			{
				FSAccessInfo fsi = FSAccessInfo.GetAccessInfo(this.FullPath);
				fsi.LastWrite = value;
				FSAccessInfo.SetAccessInfo(this.FullPath, fsi);
			}
		}

		[Builtin]
		internal class FSAccessInfo
		{
			internal DateTime Creation;
			internal DateTime LastAccess;
			internal DateTime LastWrite;
			internal int Length;

			[BuiltinMethod, BuiltinSemantics("fsaccess_getinfo")]
			[UsedModStatics("System.ExternalState.fsstate")]
			internal static FSAccessInfo GetAccessInfo(string fname)
			{ return null; }

			[BuiltinMethod, BuiltinSemantics("fsaccess_setinfo")]
			[UsedModStatics("System.ExternalState.fsstate")]
			internal static void SetAccessInfo(string fname, FSAccessInfo fsi)
			{ ;}
		}
	}
}

#pragma warning restore 0649 
